'use strict';

const BaseController = require('./BaseController');
class AudioController extends BaseController {
  async index(){
    const { ctx, app } = this;
    const query = ctx.request.query;
    query.model = 'About';
    const res = await ctx.service.page.page(query)
    ctx.body = res
  }
  async create(){
    const {ctx,app} = this;
    let params = ctx.request.body;
    console.log(params);
    ctx.model.About.create(params);
    ctx.body = {
      code:1,
      msg:"创建成功！"
    }
  }
  async update(){
    const { ctx, app } = this;
    if(ctx.params.id && Object.keys(ctx.request.body).length>0){
      console.log(ctx.request.body)
      await ctx.model.About.update(ctx.request.body,{where:{id:ctx.params.id}})
      ctx.body = {code:1,msg:"修改成功"}
    }else{
      ctx.body = {code:0,msg:"无数据修改！"}
    }
  }
}

module.exports = AudioController;
